package com.z.sys.mapper;

import com.z.sys.model.UserRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zxy
 * @since 2020-10-14
 */
public interface UserRoleMapper extends BaseMapper<UserRole> {
    @Insert("insert into sys_user_role(user_id, role_id) value(#{userId}, #{roleId})")
    void save(UserRole userRole);

    @Select("select * from sys_user_role where user_id=#{userId}")
    UserRole getUserRoleByUserId(String userId);

    @Select("select * from sys_user_role where user_id=#{userId} and role_id=#{roleId}")
    UserRole getUserRoleByUserIdAndRoleId(Integer userId, Integer roleId);

    void update(UserRole userRole);

    @Delete("delete from sys_user_role where user_id = #{userId}")
    void deleteByUserId(String id);

    @Delete("delete from sys_user_role where role_id = #{roleId}")
    void deleteByRoleId(String id);
}
